﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using AutoItX3Lib;

namespace PowerPointWebController
{
    class PowerPointKeyPress
    {
        private const string TITLE = "PowerPoint Slide Show - [";

        private static void send(string key)
        {
            AutoItX3Class a = new AutoItX3Class();

            if (a.WinExists(TITLE, "") > 0)
            {
                int ox = a.MouseGetPosX();
                int oy = a.MouseGetPosY();

                a.WinActivate(TITLE, "");

                int x = a.WinGetPosX(TITLE, "");
                int y = a.WinGetPosY(TITLE, "");

                a.MouseClick("MIDDLE", x, y, 1, 1);
                if(key != null)
                    a.Send(key, 0);

                a.MouseMove(ox, oy, 0);
            }
        }

        public static void sendRight()
        {
            send("n");
        }

        public static void sendLeft()
        {
            send("p");
        }

        public static void sendTab()
        {
            send("{TAB}");
        }

        public static void sendClick()
        {
            send("{ENTER}");
        }

        public static void showPresentation()
        {
            send(null);
        }
    }
}
